import React from "react";
import {
  PullToRefresh,
  ListView,
  Carousel,
  SwipeAction,
  Button
} from "antd-mobile";
import axios from "axios";
import { Grid, Toast } from 'antd-mobile';
import Thumbnail from "./Thumbnail";
import CardBookList from "./CardBookList";
import CardRankList from "./CardRankList";
import CardWashList from "./CardWashList";
import FormBook from "./FormBook";
import FormRank from "./FormRank";
import FormWash from "./FormWash";

axios.defaults.baseURL = '/app'
axios.defaults.headers.post['Content-Type'] = 'application/json';
const url = "/banner/user/1";
export default class Tabs extends React.Component {
  constructor(props){
    super(props);
    this.state = {
      data:props.data,
      category:props.category,
      code:props.code,
      memo:props.memo
    }
  }
  componentWillReceiveProps = (props) =>{
    this.setState({
      data:props.data,
      category:props.category,
      code:props.code,
      memo:props.memo
    })
  }
  render() {
    if(this.state.memo == 'thum'){
      return (
        <Thumbnail category={this.state.category} code={this.state.code}/>
      );
    }
    if(this.state.memo == 'card_book'){
      return (
        <CardBookList category={this.state.category} code={this.state.code} data={this.state.data}/>
      );
    }
    if(this.state.memo == 'card_rank'){
      return (
        <CardRankList category={this.state.category} code={this.state.code} data={this.state.data}/>
      );
    }
    if(this.state.memo == 'card_wash'){
      return (
        <CardWashList category={this.state.category} code={this.state.code} data={this.state.data}/>
      );
    }
    if(this.state.memo == 'form_book'){
      return (
        <FormBook category={this.state.category} code={this.state.code}/>
      );
    }
    if(this.state.memo == 'form_rank'){
      return (
        <FormRank category={this.state.category} code={this.state.code}/>
      );
    }
    if(this.state.memo == 'form_wash'){
      return (
        <FormWash category={this.state.category} code={this.state.code}/>
      );
    }
    // if(this.state.memo == 'thum'){
    //   return (
    //     <div >
    //         <Grid data={this.state.data}
    //           columnNum={3}
    //           renderItem={dataItem => (
    //             <div onClick={() => Toast.info("不要点了，疯狂暗示222")} style={{ padding: '11.5px' }} >
    //               <img src={dataItem.icon} style={{ width: '75px', height: '75px' }} alt="" />
    //               <div style={{ color: '#888', fontSize: '14px', marginTop: '8 px' }}>
    //                 <span>I am title..</span>
    //               </div>
    //             </div>
    //           )}
    //         />
    //       </div>
    //   );
    // }
    // if(this.state.memo == 'list'){
    //   return (
    //     <div >
    //         <Grid data={this.state.data}
    //           columnNum={3}
    //           renderItem={dataItem => (
    //             <div onClick={() => Toast.info("不要点了，疯狂暗示222")} style={{ padding: '11.5px' }} >
    //               <img src={dataItem.icon} style={{ width: '75px', height: '75px' }} alt="" />
    //               <div style={{ color: '#888', fontSize: '14px', marginTop: '8 px' }}>
    //                 <span>I am title..</span>
    //               </div>
    //             </div>
    //           )}
    //         />
    //       </div>
    //   );
    // }
  }
}

